package com.yisu.auction.api.web.controller;

import com.yisu.auction.api.web.interceptor.IAuthVerifyAnnotation;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * author: 赵杰
 * Business Description：APP相关业务
 * createTime：2017/9/28
 */
@Controller
@RequestMapping(value = "/app")
public class AppController {

    /**
     * author: 赵杰
     * Business Description：获取首页相关业务信息
     *
     * @param
     * @return 系统参数
     */
    @RequestMapping(value = "/appDownLoad", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=utf-8")
    public String appDownLoad(HttpServletRequest request, HttpServletResponse response) {
        String downLoadUrl="http://www.baidu.com";
        try {

            //获取ua，用来判断是否为移动端访问
            if (!StringUtils.isEmpty(request.getHeader("USER-AGENT"))) {
                String userAgent = request.getHeader("USER-AGENT").toLowerCase();
                if (userAgent.contains("android")) {
                    downLoadUrl = "http://ovqsey1r6.bkt.clouddn.com/fkjp.apk";
                } else if (userAgent.contains("iphone")||userAgent.contains("ipod")||userAgent.contains("ipad")) {
                    downLoadUrl = "https://itunes.apple.com/cn/app/id1285332000?mt=8";
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "redirect:" + downLoadUrl;
    }
}
